由于binlog未及时清理导致硬盘爆满无法启动mysql – LPC影子技术分享 | 您所在的位置:网站首页 › disk is full writing › 由于binlog未及时清理导致硬盘爆满无法启动mysql – LPC影子技术分享 |
这几天由于太忙了,7天没有观察服务器了,今天用手机打开网站发现报mysql.sock丢失的错误,刚开始以为是my.ini修改的原因,用df一看,/dev/xvda1的占用已经100%了,这样的情况还能启动mysql就真的逆天了。这时候想到了用sql删除binlog,但是根本进不去控制台,连安全模式都启动不了,以下是具体操作。 分配了20G的硬盘,活生生的被binlog吃完了。 tail -f /opt/server/mysql/var/slyar.err看了一下Mysql的错误日志,意外状况出现…… Disk is full writing './mysql-bin.~rec~' (Errcode: 28). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)神奇的情况,居然是因为磁盘满了无法写入日志导致Mysql起不来。 root@hkshadow# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvda1 20641404 20641404 0 100% /基本上就是被这些玩意占满了,查了一下Mysql手册发现这些东西也没啥用,直接删除(此操作最好在Mysql服务停止时进行,因为当前日志使用的话无法删除,而且有可能导致一些其它问题,不过用mysql>reset master命令可以直接清空日志)。 /opt/server/mysql/var/ root@hkshadow# cd root@hkshadow# rm -f mysql-bin.*如果一定要使用binlog又担心时间久了没及时清理的话,可以在my.ini里设置binlog过期时间。 expire_logs_days = 7如果不需要binlog的话可以关闭掉,避免未来得及监控导致的系列问题。 vim /etc/my.cnf注释掉下面2行 log-bin=mysql-bin binlog_format=mixed然后重启即可 /etc/init.d/mysqld restart |
CopyRight 2018-2019 实验室设备网 版权所有 |